home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
pc_board
/
rnet108u.zip
/
MAILRUN.SLT
< prev
next >
Wrap
Text File
|
1992-07-27
|
11KB
|
364 lines
// ------------------------------------------------------------------------- //
//
// PCBoard Mail Script (MAILDOOR.SLT) -- Handles the door and files;
// Login *MUST* be handled by the dialing dir script (PCBLOGIN.SLT)
//
// Robert Vostreys, FTL Sysop, 404-292-8761, 404-299-3930 HST
//
// Yeah, this script is a bit more complex than it needs to be, but I like
// to cover most (if not all) of the bases when doing automated things.
//
// ------------------------------------------------------------------------- //
//
// NOTE: All references to HOST_ID should be replaced with the actual code
// (name) assigned to your host system's mail door. Please contact your
// host to determine what their HOST_ID is.
//
// Use this script to call and up/download QWK echomail to your host system.
// Copy (or rename) this script to HOST_ID.SLT. You may leave this script
// as MAILRUN.SLT, in which case you will need to use CS MAILRUN to compile.
//
// Edit the string values below to whatever is approperate (multiple dialing
// directory entries may be placed, as shown below). The actual login to
// the host BBS MUST be handled by the autoscript entry in the dialing
// directory (see PCBLOGIN.SLT).
//
// Compile this script with CS HOST_ID.SLT (will produce HOST_ID.SLC) then
// place the resulting HOST_ID.SLC file where Telix.exe is kept.
//
// ------------------------------------------------------------------------- //
//
// To execute a mailrun, start Telix with : TELIX -sHOST_ID
// If you leave this script as MAILRUN.SLT: TELIX -sMAILRUN
//
// See the TELIX.DOC and SALT.DOC files for more information on programming
// with the SALT telix script language.
//
// ------------------------------------------------------------------------- //
str dlfilename[] = "e:\rnet\TRP.QWK"; // Used to check for existance...
str ulfilename[] = "e:\rnet\TRP.REP"; // Used for filespec in UpLoad...
str hostnumber[] = "33 34 35"; // Dialing Directory entries
str newdlpath[] = "e:\rnet\"; // Where to download the .QWK's to
int reset_baud = 19200; // baud to reset after host hangup
str holddowndir[80];
// ------------------------------------------------------------------------- //
main()
{
holddowndir = _down_dir; // change download directory so auto-zmodem
_down_dir = newdlpath; // downloads will work correctly.
dial_host(); // call host, login done by AutoScript
// in dialing directory (such as PCBLOGIN)
get_to_prompt(); // get to maildoor command prompt
get_mailpack(); // download any QWKs
send_mailpack(); // upload any existing REPs
logoff_host(); // goodbye from host, hangup
off_line(); // take the phone off-hook
exitscript(0); // exit Telix, errorlevel 0
}
// ------------------------------------------------------------------------- //
dial_host()
{
clear_scr();
prints("Dialing Host...");
cputs_tr("ATH0^M");
waitfor("OK", 5);
cputs_tr("AT^M");
waitfor("OK", 5);
dial(hostnumber, 10, 0);
if (_entry_enum == 0) exitscript(-2);
if (!carrier()) exitscript(-2);
}
// ------------------------------------------------------------------------- //
logoff_host()
{
int junk = 0;
Get_Commandprompt();
terminal();
cputs("G^M");
terminal();
status_wind("Goodbye...", 5);
terminal();
delay(10);
terminal();
delay(10);
terminal();
}
// ------------------------------------------------------------------------- //
get_to_prompt()
{
int junk = 0;
terminal();
status_wind("Waiting for door to open...", 20);
terminal();
delay(20);
terminal();
Get_Commandprompt(junk);
}
// ------------------------------------------------------------------------- //
get_mailpack() // AUTO ZMODEM DOWNLOADS ASSUMED TO BE IN USE!
{
str buffer[80];
int tmark = 0;
int t1 = 0;
int t2 = 0;
int stat = 0;
if (carrier())
{
terminal();
if (filefind(dlfilename, 0, buffer))
{
buffer = "DEL ";
strcat(buffer, dlfilename);
dos(buffer, 0);
status_wind("KILL QWK...", 10);
terminal();
}
status_wind("Request Download...", 5);
cputs("D^M");
terminal();
tmark = timer_start(9000); // wait up to 15 minutes for SCAN
t1 = track("Personal Messages", 1); // Rnet mail packet ready
t2 = track("no messages found", 1); // Rnet mail packet NOT READY
while (carrier() and (!time_up(tmark)))
{
terminal();
stat = track_hit(0);
if (stat == t1)
{
cputs("Y^M"); // yes we want the mailpack
track_free(0); // clear all track channels
timer_free(tmark); // clear all timer channels
terminal();
t1 = track(" Command?", 1); // look for prompt when done
tmark = timer_start(9000); // 15 minutes allowed for DLing
terminal();
while (carrier() and (!time_up(tmark)))
{
if (track_hit(0)) break; // at prompt... done
terminal(); // wait for download to finish
}
terminal();
track_free(0); // clear all track channels
timer_free(tmark); // clear all timer channels
break;
}
else if (stat == t2)
{
status_wind("No QWK!", 5);
break;
}
}
status_wind("QWK transfer options completed!", 10);
terminal();
}
}
// ------------------------------------------------------------------------- //
send_mailpack()
{
str buffer[80];
if (carrier())
{
if (!filefind(ulfilename, 0, buffer)) // check if we have REP to send
{
terminal();
return(0); // ...nope, get outta here.
}
cputs("U^M"); // ...yep, tell door to expect it
status_wind("Request Upload...", 5);
terminal();
if (!carrier()) return;
if (send('Z', ulfilename) != 0) // ZMODEM ASSUMED!
{
if (!carrier()) return();
clear_scr();
status_wind("KILL REP...", 10);
buffer = "DEL ";
strcat(buffer, ulfilename);
dos(buffer, 0); // delete REP packet
terminal();
status_wind("Waiting for REP insert...", 30);
terminal();
}
terminal();
}
}
// ------------------------------------------------------------------------- //
exitscript(int flag)
{
if (flag == -2)
{
status_wind("Connect NOT established!", 30);
}
if (flag == -1)
{
status_wind("Door did NOT respond!", 30);
}
off_line();
terminal();
_down_dir = holddowndir;
if (flag == -1) ExitTelix(1); // Door not available (ErrorLevel == 1)
if (flag == -2) ExitTelix(2); // No connection (ErrorLevel == 2)
ExitTelix(0); // Normal Exit (ErrorLevel == 0)
}
// ------------------------------------------------------------------------- //
off_line()
{
status_wind("Waiting for 'NO CARRIER'...", 20);
waitfor("NO CARRIER", 5);
terminal();
if (carrier()) hangup();
delay(5);
set_cparams(reset_baud, get_parity(), get_datab(), get_stopb());
cputs_tr("AT^M"); // get modem attention
waitfor("OK", 5);
terminal();
delay(5);
terminal();
cputs_tr("ATZ^M"); // reset modem to CMOS defaults
waitfor("OK", 5);
terminal();
delay(5);
terminal();
cputs_tr("ATZ^M"); // Do it again -- in case RING came in...
waitfor("OK", 5);
terminal();
delay(5);
cputs_tr("ATH1^M"); // Go off-hook
waitfor("OK", 3);
terminal();
delay(5);
cputs_tr("ATH1^M"); // Again -- just in case a RING came in...
waitfor("OK", 3);
terminal();
terminal();
status_wind("Line should now be off-hook.", 10);
exittelix(0); // Unload Telix, return to batch w/Errorlevel=0
}
// ------------------------------------------------------------------------- //
Get_Commandprompt()
{
int t1 = 0;
int t2 = 0;
int t3 = 0;
int t4 = 0;
int t5 = 0;
int stat = 0;
int statflag = 0;
int tmark = 0;
int ulflag = 0;
t1 = track("mand?", 1); // door command prompt
t2 = track("SUCCESSFULLY", 1); // DL was successful
t3 = track(" to continue", 1); // enter to continue
t4 = track("More:", 1); // more prompt
t5 = track("(N)", 1); // yipes, more more prompts!
tmark = timer_start(1800); // wait up to 3 minutes for door
cputs("^M");
while (carrier())
{
terminal();
stat = track_hit(0); // see if any track flags set
if (stat == t1) break; // at Command? prompt
if (stat == t2)
{
ulflag = 1;
break;
}
if (stat == t3) // y/n/ns
{
cputs("^M");
terminal();
timer_restart(tmark, 1800); // wait up to 3 minutes for door
}
if (stat == t4 or stat == t5)
{
cputs("N");
cputs("^M");
terminal();
delay(10);
terminal();
}
if (time_up(tmark)) // check for no activity
{
status_wind("Wakeup!", 1);
cputs("^M");
terminal();
statflag = statflag + 1;
timer_restart(tmark, 1800); // 3 minute checks now...
if (statflag > 10) exitscript(-1); // Up to 30 minutes to wakeup
}
if (statflag==2) break;
}
track_free(0); // Clear all track channels
timer_free(tmark); // Clear all timer channels
return(ulflag);
}
// ------------------------------------------------------------------------- //